#include "utime.h"
#include <time.h>
#include "./ustring.h"

namespace libzq
{
	time_t current_timestamp()
	{
		return time(NULL);
	}

	string current_timestring(int revise_sec/* = 0*/)
	{
		return std::move(posix_time2string(boost::posix_time::second_clock::local_time() + boost::posix_time::seconds(revise_sec)));
	}

	string posix_time2string(boost::posix_time::ptime&& ptime)
	{
		struct tm now = boost::posix_time::to_tm(ptime);
		return std::move(format("%d-%02d-%02d %02d:%02d:%02d", now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec));
	}

}